//
//  LMNewFeatureCell.m
//  李明微博
//
//  Created by 张青花 on 15/12/6.
//  Copyright (c) 2015年 李明. All rights reserved.
//

#import "LMNewFeatureCell.h"
#import "LMTabBarController.h"

@interface LMNewFeatureCell()

@property(nonatomic,weak)UIImageView *imageView;


@property(nonatomic,weak)UIButton *shareBtn;

@property(nonatomic,weak)UIButton *startBtn;


@end


@implementation LMNewFeatureCell


-(UIButton *)shareBtn
{
    if (_shareBtn == nil) {
        
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        
        [btn setTitle:@"分享给大家" forState:UIControlStateNormal];
        [btn setImage:[UIImage imageNamed:@"new_feature_share_false"] forState:UIControlStateNormal];
        [btn setImage:[UIImage imageNamed:@"new_feature_share_true"] forState:UIControlStateSelected];
        [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [btn sizeToFit];
        
        [self.contentView addSubview:btn];
        _shareBtn = btn;
        
    }
    return _shareBtn;
}

-(UIButton *)startBtn
{
    if (_startBtn == nil) {
        
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        
        [btn setTitle:@"开启之旅" forState:UIControlStateNormal];
        [btn setBackgroundImage:[UIImage imageNamed:@"new_feature_finish_button"] forState:UIControlStateNormal];
        [btn setBackgroundImage:[UIImage imageNamed:@"new_feature_finish_button_highlighted"] forState:UIControlStateHighlighted];
        [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [btn sizeToFit];
        
        [btn addTarget:self action:@selector(starBtn) forControlEvents:UIControlEventTouchUpInside];
        
        [self.contentView addSubview:btn];
        _startBtn = btn;
        
    }
    return _startBtn;
}

- (void)starBtn
{
    LMTabBarController *tab = [[LMTabBarController alloc] init];
    
    LMKeyWindow.rootViewController = tab;
}

-(UIImageView *)imageView
{
    if (_imageView ==nil) {
        UIImageView *view =[[UIImageView alloc] init];
        
        _imageView = view;
        [self.contentView addSubview:view];
    }
    
    return _imageView;

}


-(void)setImage:(UIImage *)image
{
    _image = image;
    self.imageView.image = image;
    
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.imageView.frame = self.bounds;
    
    self.shareBtn.center = CGPointMake(self.width * 0.5, self.height * 0.8);
    self.startBtn.center = CGPointMake(self.width * 0.5, self.height * 0.9);
}


- (void)setIndexPath:(NSIndexPath *)indexPath count:(int)count
{
    if (indexPath.row==count-1) {
        self.startBtn.hidden = NO;
        self.shareBtn.hidden = NO;
    }
    else
    {
        self.startBtn.hidden = YES;
        self.shareBtn.hidden = YES;
    }
}


@end
